Skip to content

[None][infra] Bump xgrammar#12811

Merged
niukuo merged 3 commits intoNVIDIA:release/1.2.1from
yuanjingx87:user/yuanjingx/cherry-pick-vulnerability-fix
Apr 8, 2026
Merged

[None][infra] Bump xgrammar#12811
niukuo merged 3 commits intoNVIDIA:release/1.2.1from
yuanjingx87:user/yuanjingx/cherry-pick-vulnerability-fix

Conversation

@yuanjingx87
Copy link
Copy Markdown
Collaborator

@yuanjingx87 yuanjingx87 commented Apr 7, 2026

Summary by CodeRabbit

  • Chores
    • Updated dependency to version 0.1.32
    • Enhanced build process with automated patching mechanism

Description

Bump xgrammar

Test Coverage

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

Signed-off-by: Yuanjing Xue <197832395+yuanjingx87@users.noreply.github.com>
@yuanjingx87 yuanjingx87 requested a review from a team as a code owner April 7, 2026 19:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Updated the xgrammar dependency from version 0.1.25 to 0.1.32 across build and Python configuration files. Added a patch file that applies constexpr optimizations to GrammarFunctor flag constants during the build process.

Changes

Cohort / File(s) Summary
CMake Configuration
3rdparty/CMakeLists.txt
Bumped xgrammar GIT_TAG from v0.1.25 to v0.1.32; added PATCH_COMMAND to apply patches/xgrammar_constexpr.patch with dry-run validation.
Build Patch File
3rdparty/patches/xgrammar_constexpr.patch
New patch file that changes five GrammarFunctor flag constants from static const int16_t to static constexpr int16_t (kNotEndStateFlag, kEndStateFlag, kSelfRecursionFlag, kSimpleCycleFlag, kUnKnownFlag).
Python Dependencies
requirements.txt, security_scanning/pyproject.toml
Updated xgrammar pinned version from 0.1.25 to 0.1.32 in both Python dependency files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is minimal and incomplete, lacking key details about why the dependency is being bumped (motivation, bug fixes, features), what version changes are involved, and test coverage information. Add details explaining the reason for the bump (e.g., bug fixes, security updates), specify version changes (0.1.25 to 0.1.32), and document relevant test coverage or validation performed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[None][infra] Bump xgrammar' clearly and concisely describes the main change: updating the xgrammar dependency as an infrastructure change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
3rdparty/CMakeLists.txt (1)

111-123: Patch command error handling may mask real failures.

The current logic uses || to catch any failure, but this could mask genuine patch application errors. If the dry-run succeeds but the actual patch command fails for reasons other than "already applied" (e.g., file corruption, permission issues), the error is silently swallowed with a misleading message.

🛠️ Suggested improvement for more robust error handling
-  PATCH_COMMAND
-    bash -c "patch -p1 --forward --batch --dry-run -i '${_patch_file}' && \
-    patch -p1 --forward --batch -i '${_patch_file}' || \
-    echo 'Patch already applied, skipping.'")
+  PATCH_COMMAND
+    bash -c "if patch -p1 --forward --batch --dry-run -i '${_patch_file}' 2>/dev/null; then \
+      patch -p1 --forward --batch -i '${_patch_file}'; \
+    else \
+      echo 'Patch already applied or not applicable, skipping.'; \
+    fi")

This ensures that if the dry-run fails (patch already applied), we skip gracefully, but if the dry-run succeeds and the actual patch fails, the error propagates correctly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@3rdparty/CMakeLists.txt` around lines 111 - 123, The PATCH_COMMAND currently
swallows real patch failures by using "&& ... || echo", so replace that shell
compound with an explicit conditional that runs the dry-run then, only if the
dry-run succeeds, runs the real patch and lets its error propagate; otherwise
print "Patch already applied, skipping." Update the PATCH_COMMAND (referencing
_patch_file and the FetchContent_Declare for xgrammar) to use: bash -c "if patch
-p1 --forward --batch --dry-run -i '${_patch_file}'; then patch -p1 --forward
--batch -i '${_patch_file}'; else echo 'Patch already applied, skipping.'; fi"
so dry-run failures skip but actual patch failures are not masked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@3rdparty/CMakeLists.txt`:
- Around line 111-123: The PATCH_COMMAND currently swallows real patch failures
by using "&& ... || echo", so replace that shell compound with an explicit
conditional that runs the dry-run then, only if the dry-run succeeds, runs the
real patch and lets its error propagate; otherwise print "Patch already applied,
skipping." Update the PATCH_COMMAND (referencing _patch_file and the
FetchContent_Declare for xgrammar) to use: bash -c "if patch -p1 --forward
--batch --dry-run -i '${_patch_file}'; then patch -p1 --forward --batch -i
'${_patch_file}'; else echo 'Patch already applied, skipping.'; fi" so dry-run
failures skip but actual patch failures are not masked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 23334802-fc91-4080-a374-c17b6bb7fce8

📥 Commits

Reviewing files that changed from the base of the PR and between 3c13d8c and 994b9b3.

📒 Files selected for processing (4)
  • 3rdparty/CMakeLists.txt
  • 3rdparty/patches/xgrammar_constexpr.patch
  • requirements.txt
  • security_scanning/pyproject.toml

@yuanjingx87
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42181 [ run ] triggered by Bot. Commit: 994b9b3 Link to invocation

Signed-off-by: Yuanjing Xue <197832395+yuanjingx87@users.noreply.github.com>
@yuanjingx87
Copy link
Copy Markdown
Collaborator Author

/bot run --stage-list "Build-Docker-Images"

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42187 [ run ] triggered by Bot. Commit: c2d6bb7 Link to invocation

@yuanjingx87 yuanjingx87 force-pushed the user/yuanjingx/cherry-pick-vulnerability-fix branch from c2d6bb7 to b07c6a7 Compare April 7, 2026 22:45
@yuanjingx87
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42187 [ run ] completed with state FAILURE. Commit: c2d6bb7
/LLM/release-1.2.1/L0_MergeRequest_PR pipeline #11 (Partly Tested) completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42196 [ run ] triggered by Bot. Commit: b07c6a7 Link to invocation

@yuanjingx87 yuanjingx87 force-pushed the user/yuanjingx/cherry-pick-vulnerability-fix branch from b07c6a7 to a107811 Compare April 8, 2026 00:31
@yuanjingx87
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42196 [ run ] completed with state SUCCESS. Commit: b07c6a7
/LLM/release-1.2.1/L0_MergeRequest_PR pipeline #12 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42206 [ run ] triggered by Bot. Commit: a107811 Link to invocation

@yuanjingx87
Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42265 [ run ] triggered by Bot. Commit: 8c58294 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #42265 [ run ] completed with state SUCCESS. Commit: 8c58294
/LLM/release-1.2.1/L0_MergeRequest_PR pipeline #16 completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

@niukuo niukuo merged commit 9532fed into NVIDIA:release/1.2.1 Apr 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants